﻿Namespace Producto


    Public Class frmProductoBuscar

        Public Sub LoadParameter()
            'cargarCombo FormaSimple
            CargarFormaSimple()
            CargarFormaCompuesta(Me.cbbFormaSimple.SelectedValue)
            CargarMarca()
            CargarTipo()
            Listar()
        End Sub
        Public Sub CargarTipo()
            Dim obj As New Farmacia.Business.Producto.Tipo
            Dim ocol As Farmacia.Entity.Producto.TipoCol
            ocol = obj.Combo(True)
            Me.cbbTipo.DisplayMember = "Nombre"
            Me.cbbTipo.ValueMember = "TipoId"
            Me.cbbTipo.DataSource = ocol
        End Sub
        Public Sub CargarMarca()
            Dim obj As New Farmacia.Business.Producto.Marca
            Dim ocol As Farmacia.Entity.Producto.MarcaCol
            ocol = obj.Combo(True)
            Me.cbb_marca.DisplayMember = "Nombre"
            Me.cbb_marca.ValueMember = "MArcaId"
            Me.cbb_marca.DataSource = ocol
        End Sub

        Public Sub CargarFormaSimple()
            Dim obj As New Farmacia.Business.Producto.FormaSimple
            Dim ocol As Farmacia.Entity.Producto.FormaSimpleCol
            ocol = obj.Combo(True)
            Me.cbbFormaSimple.DisplayMember = "Nombre"
            Me.cbbFormaSimple.ValueMember = "FormaSimpleId"
            Me.cbbFormaSimple.DataSource = ocol
        End Sub

        Public Sub CargarFormaCompuesta(ByVal vFormaSimpleId As Integer)
            Dim obj As New Farmacia.Business.Producto.FormaCompuesta
            Dim oCol As Farmacia.Entity.Producto.FormaCompuestaCol
            oCol = obj.Combo(vFormaSimpleId, True)
            Me.cbbFormaCompuesta.DisplayMember = "Nombre"
            Me.cbbFormaCompuesta.ValueMember = "FormaCompuestaID"
            Me.cbbFormaCompuesta.DataSource = oCol
        End Sub


        Public Sub Listar()
            Dim obj As New Farmacia.Business.Producto.Producto
            Dim oCOl As Farmacia.Entity.Producto.ProductoCol
            oCOl = obj.Listar(-1, -1, -1, _
                                Me.cbbTipo.SelectedValue, _
                                Me.cbb_marca.SelectedValue, _
                               Me.txt_nombre.Text, _
                                Me.txtcodigo.Text, _
                                  Me.cbbFormaSimple.SelectedValue, _
                                Me.cbbFormaCompuesta.SelectedValue, _
                                "", _
                                  "", _
                                  -1, _
                                   "", _
                                    -1, _
                                   -1, _
                                   -1,
                                   "", _
                                    "")
            Me.dgw_catalogo.AutoGenerateColumns = True
            Me.dgw_catalogo.DataSource = oCOl


        End Sub


        Private Sub frmCatalogoBuscar_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
            LoadParameter()
        End Sub

        Private Sub cbbFormaSimple_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbbFormaSimple.SelectedIndexChanged
            CargarFormaCompuesta(Me.cbbFormaSimple.SelectedValue)
        End Sub



        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBuscar.Click
            Listar()
        End Sub

        Private Sub btn_AgregarProducto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_AgregarProducto.Click
            Dim frm As New frmProductoMant
            frm.ProductoID = -1
            'frm.MdiParent = Me
            If frm.ShowDialog = Windows.Forms.DialogResult.OK Then
                Listar()
            End If
        End Sub

        Private Sub frmProductoBuscar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        End Sub
    End Class
End Namespace